/*
 * Copyright 2008, 2009 Kobi Krasnoff
 * 
 * This file is part of "Catch Falling Coins".
 *
 * "Catch Falling Coins" is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * "Catch Falling Coins" is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with "Catch Falling Coins".  If not, see <http://www.gnu.org/licenses/>.
 *
 */

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class MainMIDlet extends MIDlet {
	
	private MainScreenCanvas mainScreenCanvas;
	private SplashWithText splashWithText;
	private Display display;
	private CopyrightForm copyrightForm;
	private MainList mainList;

	public MainMIDlet() {
		mainScreenCanvas = new MainScreenCanvas(this);
		splashWithText = new SplashWithText(this, 0, "Welcome Screen");
		copyrightForm = new CopyrightForm(this);
		mainList = new MainList(this);
		display = Display.getDisplay(this);
		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		

	}

	protected void pauseApp() {
		

	}

	protected void startApp() throws MIDletStateChangeException {
		display.setCurrent(splashWithText);
		
	}
	
	public void setCurrent(String d) {
		if (d == "CopyrightForm" || d == "AboutForm") {
        	display.setCurrent(copyrightForm);
        }
		else if (d == "MainList") {
			mainList.deleteContinue();
			display.setCurrent(mainList);
		}
		else if (d == "Start Game") {
			mainScreenCanvas.setInitValues();
			display.setCurrent(mainScreenCanvas);
		}
		else if (d == "Continue") {
			display.setCurrent(mainScreenCanvas);
		}
		else if (d == "GameOver") {
			splashWithText = new SplashWithText(this, 0, "Game Over");
			display.setCurrent(splashWithText);
		}
	}
	
	public void addContinue()
	{
		mainList.addContinue();
	}
	
	public void deleteContinue()
	{
		mainList.deleteContinue();
	}
	
	public void exitMIDlet() {
        notifyDestroyed();
    }
	
	
}
